package org.jeecg.modules.nation.controller;


import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.common.api.vo.Result;
import org.jeecg.modules.nation.entity.Nation;
import org.jeecg.modules.nation.service.NationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author liujiamiao
 * @email 2544296058@qq.com
 * @since 2020-10-21
 */
@RestController
@RequestMapping("/nation/nation")
@Slf4j
@Api(tags = "民族接口")
public class NationController {

    @Autowired
    private NationService nationService;

    /**
     * 获取所有的民族信息
     * @return
     */
    @ApiOperation("获取所有的民族信息")
    @GetMapping("/list")
    public Result list(){
        List<Nation> list = nationService.list();
        return Result.ok(list);
    }

    /**
     * 根据id获取民族信息
     * @param id
     * @return
     */
    @ApiOperation("根据id获取民族信息")
    @GetMapping("/info/{id}")
    public Result info(@ApiParam("nationId") @PathVariable("id") Integer id){
        Nation nation = nationService.getById(id);
        return  Result.ok(nation);
    }

}

